package nl.unimaas.group11.project1_3.graphics;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;

import javax.swing.JPanel;

import nl.unimaas.group11.project1_3.algo.DataProcessor;

public class TwoDimView extends JPanel {
	private static final long serialVersionUID = 1L;

	public void paint(Graphics g) {

		super.paint(g);
		Graphics2D g2 = (Graphics2D) g;
		g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
		setBackground(Render.MEDIUM_GREY_COLOR);

		int[][][] container = DataProcessor.solutionCopy;

		for (int a = 0; a < container.length; a++) {

			for (int b = 0; b < container[0].length; b++) {

				for (int c = 0; c < container[0][0].length; c++) {

					int s = 10;

					int boxNumber = container[a][b][c];

					if (boxNumber == 0) {
						g2.setColor(Color.GRAY);

					}

					else if (DataProcessor.pents) {

						if (boxNumber == 1) {
							g2.setColor(Color.RED);
						} else if (boxNumber == 2) {
							g2.setColor(Color.BLUE);
						} else {
							g2.setColor(Color.GREEN);
						}

					} else {

						if (boxNumber == 1 || boxNumber == 2 || boxNumber == 3) {
							g2.setColor(Color.RED);

						} else if (boxNumber == 4 || boxNumber == 5 || boxNumber == 6 || boxNumber == 7 || boxNumber == 8 || boxNumber == 9) {
							g2.setColor(Color.BLUE);
						} else {
							g2.setColor(Color.GREEN);
						}
					}

					g2.fill3DRect(a * s, b * s + c * (container[0].length + 1) * s, s, s, true);

				}
			}
		}

	}
}
